package cn.com.lyb.asyncTask.manage;

import cn.com.lyb.asyncTask.construnctor.AsyncTaskConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 异步任务执行器
 * @author wangchen
 */
@Component
public class AsyncTaskExecutor {

    private static Logger LOG = LoggerFactory.getLogger(AsyncTaskExecutor.class);

    @Async
    public void executor(AsyncTaskConstructor asyncTaskGenerator, String taskId) {
        LOG.info("thread:{}, AsyncTaskExecutor is executing async task:{}", Thread.currentThread().getName(), taskId);
        asyncTaskGenerator.async();
    }
}
